package com.cogent.dao.type;

public class QueryType {
	
	/**
	 * 等于查询
	 */
	public static int EQUAL = 1;
	
	/**
	 * 大于查询
	 */
	public static int GREATER = 2;
	
	/**
	 * 大于等于
	 */
	public static int GREATERANDEQUAL = 3;
	
	/**
	 * 小于
	 */
	public static int LESS = 4;
	
	/**
	 * 小于
	 */
	public static int LESSANDEQUAL = 5;
	
	/**
	 * 左匹配
	 */
	public static int LEFTMATCH = 6;
	
	/**
	 * 右匹配
	 */
	public static int RIGHTMATCH = 7;
	
	/**
	 * 全模糊
	 */
	public static int ALLFUZZYMATCH = 8;
	
	/**
	 * 在某个范围内
	 */
	public static int INARRAY = 9;
	
	/**
	 * like在某几个范围内
	 */
	public static int LIKEINARRAY = 10;
	
	/**
	 * 数据库当前系统时间
	 */
	public static String DB_SYSDATE = "DB_DATE";
	
	public static String getQueryString(int type) {
		switch(type) {
			case 1 : return "=?";
			case 2 : return ">?";
			case 3 : return ">=?";
			case 4 : return "<?";
			case 5 : return "<=?";
			case 6 : return " like ?";
			case 7 : return " like ?";
			case 8 : return " like ?";
			case 9 : return " in (";
			case 10 : return " like ?";
		}
		
		return "=?";
	}
	
	public static String getParamValue(int type, String val) {
		switch(type) {
			case 6 : return val + "%";
			case 7 : return "%" + val;
			case 8 : return "%" + val + "%";
			case 9 : return "(" + val + ")";
			case 10 : return val + "%";
		}
		
		return val;
	}
}
